package com.zmn.brs.common.enums;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：表达式
 *
 * @author chongw
 * @since 2021/05/31 18:06
 */
public enum ExpressionEnum {

    GT(">", "大于"),
    GTE(">=", "大于等于"),
    EQ("=", "等于"),
    NE("!=", "不等于"),
    LT("<", "小于"),
    LTE("<=", "小于等于");

    /**
     * 表达式
     */
    private final String expression;

    /**
     * 说明
     */
    private final String explain;

    ExpressionEnum(String expression, String explain) {
        this.expression = expression;
        this.explain = explain;
    }

    public String getExpression() {

        return expression;
    }

    public String getExplain() {

        return explain;
    }

    public static ExpressionEnum getExpressionEnum(String expression) {

        Optional<ExpressionEnum> enumOptional = Stream.of(ExpressionEnum.values())
                .filter(p -> p.expression.equalsIgnoreCase(expression)).findFirst();
        return enumOptional.orElse(null);
    }

}
